<template>
      <div id="add_dialog">
            <el-dialog
            :title="DialogData.title"
            :visible.sync="DialogData.show"
            width="50%"
            center>
            <div class="form">
                  <el-form :model="FormData" status-icon  ref="ruleForm" label-width="100px" class="demo-ruleForm">                        
                        <el-form-item label="菜单ID" v-if="DialogData.edit" >
                              <el-input type="text" v-model="FormData.id" disabled ></el-input>
                        </el-form-item>
                        <el-form-item label="菜单名称" >
                              <el-input type="text" v-model="FormData.title"  ></el-input>
                        </el-form-item>
                        <el-form-item label="菜单路由"  >
                              <el-input type="text" v-model="FormData.name" ></el-input>
                        </el-form-item>
                        <el-form-item label="菜单图标" >
                              <el-input type="text"  v-model="FormData.pic" ></el-input>
                        </el-form-item>
                        <el-form-item label="菜单状态"  >
                              <el-input type="text"  v-model="FormData.status"  ></el-input>
                        </el-form-item>
                        
                        
                  </el-form>
            </div>
            <span slot="footer" class="dialog-footer">
                  <el-button @click="DialogData.show = false">取 消</el-button>
                  <el-button type="primary" @click="SubForm">确 定</el-button>
            </span>
            </el-dialog>
      </div>
</template>

<script>
     
      export default {
            props: {
                  DialogData: Object,
                  FormData: Object,
                  
            },
            computed: {
                
                  token() {
                        return localStorage.miniToken
                  },
                  isEdit() {
                        return this.DialogData.add ? false : true
                  }
            },
            data() {
                  return {
                        isActive: "1",
                        area: [],
                        areaEdit: false,
                  }
            },
            
            mounted() {
                  
            },
            methods: {
                  // 提交表单
                  async SubForm() {
                        this.FormData.token = this.token
                        let { name, title, status, pic } = this.FormData
                        if (!name) {
                              this.$message.error("请输入菜单路由")
                              return false
                        } else if (!title) {
                              this.$message.error("请输入菜单名称")
                              return false
                        } else if (!status) {
                              this.$message.error("请输入菜单状态")
                              return false
                        } else if (!pic) {
                              this.$message.error("请输入菜单图标 class")
                              return false
                        } else {
                              let  res = await this.$axios.post("/admin/role/menu_module_alter", this.FormData)
                              console.log(res);
                              if (res.data.code == 202 || res.data.code == 204) {
                                    this.$message.success("更新成功!")
                                    this.$emit("update")
                                    this.DialogData.show = false
                              }
                        }
                  },
            },
      }
</script>

<style lang="scss" scoped>

</style>